﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebInterface
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnConnexion_Click(object sender, EventArgs e)
        {
            LabelErreur.Visible = false;

            bool ok = false;
            IList<DotConferenceCore.GestionParticipant.Participant> participants =
                DataManager.ParticipantDataManager.Instance.GetBy(string.Format("Identifiant='{0}'", TextIdentifiant.Text));

            if( participants.Count > 0)
            {
                if(participants[0].Authentification(TextIdentifiant.Text,TextMotDePasse.Text))
                {
                    MesVariablesSessions.Instance.unParticipant = participants[0];
                    Response.Redirect("Default.aspx");
                    ok = true;
                }
            }

            if (ok == false)
                LabelErreur.Visible = true;
         
        }
    }
}
